home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9503 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: big problem with a very small program:please help me!
  5. Date: 11 Mar 1996 07:59 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <11MAR199607591679@erich.triumf.ca>
  9. References: <4hqc8p$njh@aldebaran.sct.fr>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4hqc8p$njh@aldebaran.sct.fr>, escali_m@worldnet.net (Marc Escalier) writes...
  14. >#include <stdio.h>
  15. >#include <math.h>
  16. >main()
  17. >{
  18. >float i;
  19. >i=5.25;
  20. >printf("i is real:l%f\n",i);    /* display 5.25000000000000... ok! */
  21. >printf("i is integer%d\n",i);    /* display 0  what does that mean ?!?*/
  22.  
  23. If you lie to the compiler,, it will get it's revenge!
  24.  
  25. %d tells the printf() that you are giving it an int, but you are actually
  26. giving it a float, (which will actually be promoted to double before printf()
  27. sees it).  Printf() will only take as much of the float (double) as is needed 
  28. to represent an int, and display the resulting value.
  29.  
  30. >please answer by email because i don't read often comp.lang.c.
  31.  
  32. This is not a write-only newsgroup - if you ask a question here, you should be
  33. prepared to watch for an answer here...
  34. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  35. Internet: bennett@triumf.ca         | of one another only when one can be
  36. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  37. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  38. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  39. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.